package org.dandelion.papercheck.controller;

import org.dandelion.papercheck.annotation.PassToken;
import org.dandelion.papercheck.service.PaperService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class PaperController {
    private static final Logger logger = LoggerFactory.getLogger(PaperController.class);
    private final PaperService paperService;

    @Autowired
    public PaperController(PaperService paperService) {
        this.paperService = paperService;
    }

    @PostMapping("/split")
    @PassToken
    public List<String> split(@RequestParam String fileName) throws Exception {
        return paperService.splitWordsOfFile(fileName);
    }
}
